package cn.bx.bid.entity;

//import com.alibaba.fastjson.annotation.JSONField;
//import org.springframework.format.annotation.DateTimeFormat;

//import io.swagger.annotations.ApiModel;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;


//@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
// 如果修改拿不到值 可能在转化成json的时候，fasterxml.jackson将对象转换为json报错，加这个注解
@Data
@Entity
public class User implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    private long role;
    private String username;

    @Column(name = "password",updatable = false)
    private String password;

    private String name;
    private String telephone;
    private String unit;

    private String landmark;
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date enterdate;

    //关联
    @ManyToOne//association
    @JoinColumn(name = "role",insertable = false,updatable = false)
    private Userrole r;

    public User(){};

    public User(long id,long role, String username, String password, String name) {
        this.id=id;
        this.role = role;
        this.username = username;
        this.password = password;
        this.name = name;
    }
}
